class Solution {
public:
    int ret = 0;
    void dfs(vector<int>& nums, int sum, int i, int target)
    {
        if(i == nums.size())
        {
            if(target == sum) ret++;
            return;
        }
        dfs(nums, sum + nums[i], i + 1, target);
        dfs(nums, sum - nums[i], i + 1, target);
    }
    int findTargetSumWays(vector<int>& nums, int target) {
        dfs(nums, 0, 0, target);
        return ret;
    }
};